package com.ant.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ant.annotation.AccessLimit;
import com.ant.domain.Result;
import com.ant.domain.StatusCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 党怡承
 * @version 1.0
 * @date 2021-08-04 11:34
 * @description
 * @copyright 2021
 */
@RestController
@RequestMapping("/access")
public class AccessController {

  @AccessLimit(seconds = 10,maxCount = 3)
  @GetMapping("/test")
  public JSONObject access() throws JsonProcessingException {
    Result result = new Result(true, StatusCode.OK, "请求成功");
    JSONObject jsonObject = (JSONObject) JSONArray.toJSON(result);
    return jsonObject;
  }
}
